#if (FEATURE_MODE == 0)
/**
 @file ctc_usw_srv6_cli.c

 @date 2019-11-10

 @version v5.0

 The file apply clis of srv6 module
*/

#include "sal.h"
#include "ctc_cli.h"
#include "ctc_cli_common.h"
#include "ctc_debug.h"
#include "ctc_error.h"
#include "ctc_api.h"
#include "ctcs_api.h"
#include "ctc_usw_srv6_cli.h"

extern int32
sys_usw_srv6_set_sid_format(uint8 lchip, ctc_srv6_global_cfg_t* p_global_cfg);
extern int32
sys_usw_srv6_show_status(uint8 lchip);

CTC_CLI(ctc_cli_usw_srv6_set_global_cfg,
        ctc_cli_usw_srv6_set_global_cfg_cmd,
        "srv6 global-config (sid-format FORMAT)",
        "SRv6 module",
        "Global config for SRv6",
        "sid format",
        "format"
        )
{
    ctc_srv6_global_cfg_t global_cfg;
    uint32 index = 0xFF;
    int32 ret = CLI_ERROR;

    sal_memset(&global_cfg, 0 ,sizeof(global_cfg));

    index = CTC_CLI_GET_ARGC_INDEX("sid-format");
    if (0xFF != index)
    {
        CTC_CLI_GET_UINT8("sid-format", global_cfg.sid_format_bmp, argv[index + 1]);
    }

    ret = sys_usw_srv6_set_sid_format(g_api_lchip, &global_cfg);

    if (ret)
    {
        ctc_cli_out("%% %s \n\r", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_srv6_show_status,
        ctc_cli_srv6_show_status_cmd,
        "show srv6 status",
        "Show",
        "SRv6 module",
        "Status"
        )
{
    int32 ret = 0;

    ret = sys_usw_srv6_show_status(g_api_lchip);

    if (ret < 0)
    {
        ctc_cli_out("ret = %d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;
}


int32
ctc_usw_srv6_cli_init(void)
{
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_srv6_set_global_cfg_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_srv6_show_status_cmd);

    return CLI_SUCCESS;
}

int32
ctc_usw_srv6_cli_deinit(void)
{
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_srv6_set_global_cfg_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_srv6_show_status_cmd);

    return CLI_SUCCESS;
}

#endif
